<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            function countDown() {
                let DoubleEl = new Date(2022, 10, 11).getTime();
                let today = new Date().getTime();
                let dTime = DoubleEl - today;
                let day = Math.floor(dTime / (1000 * 60 * 60 * 24));
                let dhours = dTime % (1000 * 60 * 60 * 24);
                let hours = Math.floor(dhours / (1000 * 60 * 60));
                let dminute = dhours % (1000 * 60 * 60);
                let minute = Math.floor(dminute / (1000 * 60));
                let dsecond = dminute % (1000 * 60);
                let second = Math.floor(dsecond / 1000);
                function addZero(num) {
                    return (num + "").length < 2 ? "0" + num : num;
                }
                console.log(
                    `距离双十一还有${day}天${addZero(hours)}小时${addZero(
                        minute
                    )}分钟${addZero(second)}秒`
                );
            }
            setInterval(() => {
                console.clear();
                countDown();
            }, 1000);
        </script>
    </body>
</html>
